<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>isValidJSON</title>
</head>

<body>
    <script>
        const isValidJSON = val => {
            try {
                JSON.parse(val);
                return true;
            } catch (error) {
                return false;
            }
        };
        document.write(`isValidJSON('{"name":"Adam","age":20}')的结果是:${isValidJSON('{"name":"Adam","age":20}')}`)
    </script>
</body>

</html>